﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace David_Albert
{
    public partial class FormModificarAutor : Form
    {
        Autor a;
        public FormModificarAutor(Autor a)
        {
            InitializeComponent();
            this.txtidA.Text = a.IdAutor.ToString();
            this.txtNomA.Text = a.Nom.ToString();
            this.txtCognA.Text = a.Cognom.ToString();
        }

        private void FormModificarAutor_Load(object sender, EventArgs e)
        {

        }

        private void btnModificarAcceptar_Click(object sender, EventArgs e)
        {
            try
            {
                BaseDeDades.actualitzarAutor(int.Parse(txtidA.Text), txtNomA.Text.ToString(), txtCognA.Text.ToString());
                MessageBox.Show("Autor modificat correctament", "Informacio", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            catch (Exception n)
            {
                MessageBox.Show("No s'ha pogut modificar l'autor", "Autor", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }

        private void btnModificarAutorCancelar_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void txtidA_TextChanged(object sender, EventArgs e)
        {

        }



        
    }
}
